package com.lei.session.servlet;

import java.io.IOException;
import java.util.Optional;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.lei.session.entity.LoginLog;
import com.lei.session.entity.Page;
import com.lei.session.service.LoginLogService;
import com.lei.session.service.impl.LoginLogServiceImpl;

public class LoginLogServlet extends HttpServlet {
	private LoginLogService loginLogService= new LoginLogServiceImpl();
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String currentPageStr = req.getParameter("currentPage");
//		int currentPageNo = Optional.ofNullable(currentPageNoStr).map(e->Integer.parseInt(e)).orElse(1);
		int currentPage = Optional.ofNullable(currentPageStr).map(Integer::parseInt).orElse(1);
		int pageSize= 3;
		Page<LoginLog> page = loginLogService.page(currentPage, pageSize);
		//查询数据库
		req.setAttribute("page", page);
		req.getRequestDispatcher("session/loginLog.jsp").forward(req, resp);
	}

}
